package utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

import level.Level;

public class MapUtil {
	public static void saveMap(Level level,int number){
		try {
			ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("level/level"+number));
			objectOutputStream.writeObject(level);
			objectOutputStream.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	public static Level readLevel(int i){
		Level level = null;
				ObjectInputStream objectInputStream;
				try {
					objectInputStream = new ObjectInputStream(new FileInputStream("level/level"+i));
					level = (Level)objectInputStream.readObject();
					objectInputStream.close();
				} catch (Exception e) {
					e.printStackTrace();
				
		} 
		return level;
	}
}
